import org.springframework.aop.MethodBeforeAdvice;

import java.lang.reflect.Method;

/**
 * Created with IntelliJ IDEA.
 * User: ttq
 * Date: 13-8-8
 * Time: 上午8:59
 * To change this template use File | Settings | File Templates.
 */
public class MethodBeforeInterceptor implements MethodBeforeAdvice {
    public void before(Method method, Object[] args, Object instance) throws Throwable {
        System.out.println("即将要执行方法:" + method.getName());
        if (instance instanceof AopServiceImpl) {
            String name = ((AopServiceImpl) instance).getName();
            if (name == null) {
                throw new NullPointerException("name属性不能为null");
            }
        }
    }
}
